package com.wry.controller;

import com.wry.api.SpikeService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController("spike")
public class SpikeController {

    @Resource
    private SpikeService spikeService;

    @GetMapping("/sync")
    public ResponseEntity<HttpStatus> syncStock(){
        spikeService.sync();
        return ResponseEntity.ok(HttpStatus.OK);
    }

    @GetMapping("/ms/{goodsId}")
    public ResponseEntity<String> spike(@PathVariable Long goodsId){
    return ResponseEntity.ok(spikeService.spike(goodsId));
    }

    @GetMapping("/pay/{orderId}")
    public ResponseEntity<String> pay(@PathVariable Long orderId){
        return ResponseEntity.ok(spikeService.pay(orderId));
    }
}
